<template>
	<view>
		<SpotAdd></SpotAdd>
		<view class="spots" v-for="v in list" :key="v.id" @click="to(v.id)">
			<view class="left">
				<view class="tit">
					{{v.title}}
				</view>
				<view class="datas">
					{{v.author}} {{v.time}}
				</view>
			</view>
			<image class="right" :src="v.imgs!=null ? v.imgs : '/static/message/tu.png'"></image>
		</view>

	</view>
</template>

<script>
	import SpotAdd from "../../components/SpotAdd/SpotAdd.vue"
	import {
		getarticlelist,
		list
	} from "../../api/user.js"
	// import {getdata} from "../../filters/getDateDiff.js"
	export default {
		data() {
			return {
				pageData: {
					page: 1,
					pagesize: 10
				},
				list: []
			};
		},
		components: {
			SpotAdd
		},
		created() {
			this.gitlist()
		},
		onReachBottom() {
			this.pageData.page++
			this.gitlist()
		},
		methods: {
			async gitlist() {
				let res = await getarticlelist(this.pageData)
				// console.log(res);

				// this.list = res.data
				// console.log(this.list);
				res.data.forEach(v => {
					this.list.push(v)
				})
			},
			to(id) {
				uni.navigateTo({
					url: '/pages/spot/info?id=' + id

				})
			}
		}
	}
</script>

<style lang="scss">
	.spots {
		width: 95%;
		margin: 0 auto;
		border-bottom: 1px solid #ccc;
		padding: 40rpx 0;
		display: flex;
		justify-content: space-between;

		.left {
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			width: 60%;

			.tit {
				font-size: 40rpx;
				font-weight: bolder;
				line-height: 1;
			}

			.datas {
				font-weight: bold;
				color: #c0c0c0;
			}
		}

		.right {
			width: 200rpx;
			height: 150rpx;

			padding-left: 40rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}
	}
</style>